package com.passer.labyrinth.core.entity;

public class Node implements Comparable<Node> {
    public int x, y; // 节点坐标
    public int g, h; // g: 从起点到当前节点的实际代价, h: 启发式估计代价
    public Node parent; // 父节点，用于回溯路径

    public Node(int x, int y, int g, int h, Node parent) {
        this.x = x;
        this.y = y;
        this.g = g;
        this.h = h;
        this.parent = parent;
    }

    public int getF() {
        return g + h;
    }

    @Override
    public int compareTo(Node other) {
        return Integer.compare(this.getF(), other.getF());
    }
}
